/**
   @file sys_usw_l2_fdb.h

   @date 2013-07-19

   @version v2.0

   The file defines Macro, stored data structure for Normal FDB module
 */
#ifndef _SYS_USW_L2_FDB_H_
#define _SYS_USW_L2_FDB_H_
#ifdef __cplusplus
extern "C" {
#endif

#include "sal.h"
#include "ctc_const.h"
#include "ctc_hash.h"
#include "ctc_vector.h"
#include "ctc_spool.h"
#include "ctc_l2.h"
#include "sys_usw_chip.h"
#include "sys_usw_nexthop_api.h"


#define REGULAR_INVALID_FID(fid)    ((fid == 0)||(!pl2_usw_master[lchip] || ((fid) > pl2_usw_master[lchip]->cfg_max_fid)))

#define SYS_L2_FID_CHECK(fid)         \
    if (REGULAR_INVALID_FID(fid))     \
    {                                 \
        return CTC_E_BADID; \
    }

#define SYS_L2_MAX_BLACK_HOLE_ENTRY  128
#define FAIL(r)                 ((r) < 0)
#define FDB_ERR_RET_UL(r)       CTC_ERROR_RETURN_WITH_UNLOCK((r), pl2_usw_master[lchip]->l2_mutex)
#define FDB_SET_MAC(d, s)       sal_memcpy(d, s, sizeof(mac_addr_t))
#define FDB_SET_HW_MAC(d, s)    SYS_USW_SET_HW_MAC(d, s)
#define SYS_FDB_DISCARD_FWD_PTR    0
#define DISCARD_PORT               0xFFFF

#define SYS_FDB_DBG_OUT(level, FMT, ...) \
    CTC_DEBUG_OUT(l2, fdb, L2_FDB_SYS, level, FMT, ## __VA_ARGS__)

#define SYS_L2_DUMP_SYS_INFO(psys)                                        \
    {                                                                     \
        SYS_FDB_DBG_OUT(CTC_DEBUG_LEVEL_INFO, "@@@@@ MAC[%s]  FID[%d]\n"                       \
                         "     gport:0x%x,   key_index:0x%x\n" \
                         "     ad_index:0x%x\n",                          \
                         sys_output_mac((psys)->addr.l2_addr.mac), (psys)->addr.l2_addr.fid,        \
                         (psys)->addr.l2_addr.gport, (psys)->key_index, \
                         (psys)->ad_index);                               \
    }

/* From TsingMa.MX */
#define SYS_DEFAULT_ENTRY_MAX_CID 4095

#define SYS_L2_OP_FLAG(val, flag, is_set) \
    do\
    {\
         if(is_set) { \
            CTC_SET_FLAG((val),(flag)); \
         }else{ \
            CTC_UNSET_FLAG((val), (flag)); \
         }\
    }while(0)


/****************************************************************************
 *
 * Global and Declaration
 *
 *****************************************************************************/

#define  _ENTRY_

#define CONTINUE_IF_FLAG_NOT_MATCH(query_flag, flag) \
    switch (query_flag)                              \
    {                                                \
    case CTC_L2_FDB_ENTRY_STATIC:                    \
        if (!flag.is_static)                         \
        {                                            \
            continue;                                \
        }                                            \
        break;                                       \
                                                     \
    case  CTC_L2_FDB_ENTRY_DYNAMIC:                  \
        if (flag.is_static)                          \
        {                                            \
            continue;                                \
        }                                            \
        break;                                       \
                                                     \
    case CTC_L2_FDB_ENTRY_LOCAL_DYNAMIC:             \
        if (flag.remote_dynamic || flag.is_static)   \
        {                                            \
            continue;                                \
        }                                            \
        break;                                       \
                                                     \
    case CTC_L2_FDB_ENTRY_ALL:                       \
    default:                                         \
        break;                                       \
    }


#define RETURN_IF_FLAG_NOT_MATCH(query_flag, flag) \
    switch (query_flag)                            \
    {                                              \
    case CTC_L2_FDB_ENTRY_STATIC:                  \
        if (!CTC_FLAG_ISSET(flag, CTC_L2_FLAG_IS_STATIC))                       \
        {                                          \
            return 0;                              \
        }                                          \
        break;                                     \
                                                   \
    case  CTC_L2_FDB_ENTRY_DYNAMIC:                \
        if (CTC_FLAG_ISSET(flag, CTC_L2_FLAG_IS_STATIC))                        \
        {                                          \
            return 0;                              \
        }                                          \
        break;                                     \
    case  CTC_L2_FDB_ENTRY_LOCAL_DYNAMIC:                \
        if (CTC_FLAG_ISSET(flag, CTC_L2_FLAG_IS_STATIC) || CTC_FLAG_ISSET(flag, CTC_L2_FLAG_REMOTE_DYNAMIC))                        \
        {                                          \
            return 0;                              \
        }                                          \
        break;                                     \
    case CTC_L2_FDB_ENTRY_ALL:                     \
    default:                                       \
        break;                                     \
    }


#define SYS_FDB_FLUSH_FDB_MAC_LIMIT_FLAG      \
  ( DRV_FIB_ACC_FLUSH_DEC_DYNAMIC_PORT_LIMIT  \
  | DRV_FIB_ACC_FLUSH_DEC_DYNAMIC_VLAN_LIMIT  \
  | DRV_FIB_ACC_FLUSH_DEC_DYNAMIC_LIMIT  \
  | DRV_FIB_ACC_FLUSH_DEC_SYSTEM_LIMIT )

#define UTILITY
#define GET_FID_NODE          0
#define GET_FID_LIST          1

#define L2_COUNT_GLOBAL       0
#define L2_COUNT_PORT_LIST    1
#define L2_COUNT_FID_LIST     2

#define L2_TYPE_UC            0
#define L2_TYPE_MC            1
#define L2_TYPE_DF            2
#define L2_TYPE_TCAM          3

#define DEFAULT_ENTRY_INDEX(fid)            (pl2_usw_master[lchip]->dft_entry_base + (fid))
#define IS_DEFAULT_ENTRY_INDEX(ad_index)    ((ad_index) <= (pl2_usw_master[lchip]->dft_entry_base+pl2_usw_master[lchip]->cfg_max_fid))

#define L2_LOCK \
    if (pl2_usw_master[lchip] && pl2_usw_master[lchip]->l2_mutex) sal_mutex_lock(pl2_usw_master[lchip]->l2_mutex)

#define L2_UNLOCK \
    if (pl2_usw_master[lchip] && pl2_usw_master[lchip]->l2_mutex) sal_mutex_unlock(pl2_usw_master[lchip]->l2_mutex)

#define L2_DUMP_LOCK \
    if (pl2_usw_master[lchip] && pl2_usw_master[lchip]->l2_dump_mutex) sal_mutex_lock(pl2_usw_master[lchip]->l2_dump_mutex)

#define L2_DUMP_UNLOCK \
    if (pl2_usw_master[lchip] && pl2_usw_master[lchip]->l2_dump_mutex) sal_mutex_unlock(pl2_usw_master[lchip]->l2_dump_mutex)

#define SYS_L2_INIT_CHECK()        \
    {                              \
        LCHIP_CHECK(lchip);         \
        if (pl2_usw_master[lchip] == NULL)    \
        { SYS_FDB_DBG_OUT(CTC_DEBUG_LEVEL_INFO, " Feature not initialized \n");\
            return CTC_E_NOT_INIT;\
 } \
    }

#define SYS_L2_INDEX_CHECK(index)           \
do{ \
    uint32 hash_entry_num = 0;\
    sys_usw_ftm_query_table_entry_num(lchip, DsFibHost0MacHashKey_t, &hash_entry_num);\
    if ((index) >= (hash_entry_num+MCHIP_CAP(SYS_CAP_L2_FDB_CAM_NUM))) \
    { return CTC_E_INVALID_PARAM; }\
}while(0)

#define DONTCARE_FID    0xFFFF
#define DUMP_MAX_ENTRY  256
#define L2UC_INVALID_FID(fid)       (DONTCARE_FID != fid) && REGULAR_INVALID_FID(fid)

#define SYS_L2UC_FID_CHECK(fid)       \
    if (L2UC_INVALID_FID(fid))     \
    {                                 \
        SYS_FDB_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, " [FDB] Invalid FID \n");\
        return CTC_E_BADID;\
 \
    }

#define SYS_L2_IS_LOGIC_PORT(fid) (CTC_FLAG_ISSET(_sys_usw_l2_get_fid_flag(lchip, (fid)),CTC_L2_DFT_VLAN_FLAG_USE_LOGIC_PORT))

/*32bits means: 31.is_sw; 30-11.hash_node id, refer to FDB_MAC_FID_HASH_SIZE; 0-10.hash list node number id*/
#define FDB_MAC_FID_SW_QUERY_IDX_DECODE(start_idx, is_sw, hash_node_id, list_node_id) \
do{\
    if (CTC_IS_BIT_SET(start_idx,31))\
    {\
        is_sw = 1;\
        list_node_id = (start_idx &0x7ff);\
        hash_node_id = ((0x7fffffff & start_idx) >> 11);\
    }\
    else\
    {\
        is_sw = 0;\
        list_node_id = 0;\
        hash_node_id = 0;\
    }\
}while(0)

#define FDB_MAC_FID_SW_QUERY_IDX_ENCODE(next_idx, hash_node_id, list_node_id) \
do{\
    next_idx = 0;\
    CTC_BIT_SET(next_idx,31);\
    next_idx |= ((hash_node_id << 11) | list_node_id);\
}while(0)

#define SYS_FDB_XD_OFF_TRUNK0(offset, width)       ((offset + width) < 68 && offset >= 64)
#define SYS_FDB_XD_OFF_TRUNK1(offset, width)       ((offset + width) < 64 && offset >= 48)
#define SYS_FDB_XD_OFF_TRUNK2(offset, width)       ((offset + width) < 48 && offset >= 32)
#define SYS_FDB_XD_OFF_TRUNK3(offset, width)       ((offset + width) < 16)

#define SYS_DEFAULT_XD_OFF_TRUNK0(offset, width)   ((offset + width) < 68 && offset >= 64)
#define SYS_DEFAULT_XD_OFF_TRUNK1(offset, width)   ((offset + width) < 60 && offset >= 48) || ((offset + width) < 64 && offset >= 48 && offset < 60)
#define SYS_DEFAULT_XD_OFF_TRUNK2(offset, width)   (((offset + width) < 48 && offset >= 32) || ((offset + width) < 64 && offset >= 60) || \
                                                    ((offset + width) < 64 && offset >= 56) || ((offset + width) < 64 && offset >= 48))
#define SYS_FDB_MAX_XDATA_FIELD_NUM   9
#define SYS_FDB_XDATA_PROFILE_ID      0
#define SYS_DFT_XDATA_PROFILE_ID      1

typedef struct
{
    uint32        flag;      /**< ctc_l2_flag_t  CTC_L2_xxx flags*/
    uint32        key_index; /**< mac key index */
    uint32        ad_index;  /**< mac ad index */
    uint8         pending;
    uint8         rsv[3];
}sys_l2_detail_t;

typedef enum sys_l2_dsmac_base_type_e
{
    SYS_L2_DSMAC_BASE_GPORT=1,
    SYS_L2_DSMAC_BASE_TRUNK=2,
    SYS_L2_DSMAC_BASE_VPORT=0,
}sys_l2_dsmac_base_type_t;


struct sys_l2_master_s
{
    uint32      l2mc_count;          /**< multicast entry count */
    uint32      def_count;           /**< default entry count */
    uint32      ad_index_drop;       /**< all Ad share it if drop */
    uint32      dft_entry_base;      /**< index base of default entry */

    /*** soft tabls to store fdb node ***/
    ctc_hash_t*   fdb_hash;            /**< node is sys_l2_node_t, key is mac+fid*/
    ctc_spool_t * ad_spool;            /**< ds mac spool */
    ctc_vector_t* fid_vec;             /**< node is sys_l2_fid_node_t, key is fid or fid+port */
    ctc_vector_t* vport2nh_vec;        /**< node is sys_l2_vport_2_nhid_t, index is logic port */

    sal_mutex_t * l2_mutex;            /**< mutex for fdb */
    sal_mutex_t * l2_dump_mutex;       /**< mutex for dump fdb */
    uint32      cfg_vport_num;      /**< num of logic port */
    uint32      mac_fdb_bmp[SYS_L2_MAX_BLACK_HOLE_ENTRY/32];          /*bitmap for mac based fdb, dont't care fid*/
    uint32      cfg_max_fid:16;
    uint32      cfg_hw_learn:1;       /**< support hw learning. but not force all do hw learning. */
    uint32      static_fdb_limit:1;
    uint32      trie_sort_en:1;
    uint32      vp_alloc_ad_en:1;      /**< if set, indicate logic port alloc ad_index by opf when bind nexthop,only supported in SW learning mode*/
    uint32      station_move_no_learn:1;
    uint32      rsv:11;
    uint16      rchip_ad_rsv[SYS_USW_MAX_GCHIP_CHIP_ID+1];

    int32       (*sync_add_db)(uint8 lchip, ctc_l2_addr_t* l2_addr, uint32 nhid, uint32 index);
    int32       (*sync_remove_db)(uint8 lchip, ctc_l2_addr_t* l2_addr);
    int32       (*mcast_member_update_pbmp)(uint8 lchip, void* nh_mc_p, void* mem);

    uint32      search_depth;
    ctc_hash_t* ldp_hash; /*[TM.TMM] for overlay update ldp*/
    ctc_hash_t* ad_hash;  /*[TM.TMM] for overlay update ldp*/
    ctc_hash_t* nhid_hash;
    uint32 dsmac_base[SYS_L2_DSMAC_BASE_TRUNK+1];
};
typedef struct sys_l2_master_s  sys_l2_master_t ;

extern sys_l2_master_t* pl2_usw_master[CTC_MAX_LOCAL_CHIP_NUM_PP];

/****************************************************************************

         Struct Definition

*****************************************************************************/
typedef enum sys_l2_xdata_field_e
{
    SYS_FDB_XDATA_FIELD_AUX        = 0,        /* auxdata */
    SYS_FDB_XDATA_FIELD_POL        = 1,        /* policerPtr */
    SYS_FDB_XDATA_FIELD_STA        = 2,        /* u1Type 0, statsPtr */
    SYS_FDB_XDATA_FIELD_FWD        = 3,        /* u1Type 0, dsFwdPtr */
    SYS_DFT_XDATA_FIELD_AUX        = 4,        /* auxdata */
    SYS_DFT_XDATA_FIELD_CID        = 5,        /* categoryId */
    SYS_DFT_XDATA_FIELD_XDA        = 6,        /* xAdData */
    SYS_MAX_XDATA_FIELD            = 7
}sys_l2_xdata_field_t;

typedef struct sys_l2_xdata_info_e
{
    ctc_xdata_t*  info;
    uint32        field : 16;
    uint32        rsv : 16;
    uint32        value[3];
}sys_l2_xdata_info_t;

typedef struct
{
    uint32 key_index;
    uint32 ad_index;

    uint8  conflict;
    uint8  hit;
    uint8  pending;   /* mac limit reach*/
    uint8  rsv0;
}mac_lookup_result_t;
struct sys_l2_ad_param_s
{
    DsMac_m*    ds_mac;
    uint32      srv6_nhid;
    uint32      ldp;
    uint8       lchip;
};
typedef struct sys_l2_ad_param_s sys_l2_ad_param_t;

struct sys_l2_ad_s
{
    uint32      index:24;
    uint32      ldp_en :1;   /*in ldp list*/
    uint32      rsv:7;

    uint32      calc_key_len[0];
    sys_l2_ad_param_t param;
};
typedef struct sys_l2_ad_s sys_l2_ad_t;

struct sys_l2_vport_2_nhid_s
{
    uint32 nhid;
    uint32 ad_idx:24;
    uint32 use_ldp:1;
    uint32 rsv:7;
    uint32 ad_idx1;
};
typedef struct sys_l2_vport_2_nhid_s   sys_l2_vport_2_nhid_t;

/**
   @brief stored in vlan_fdb_list.
 */
typedef struct
{
    uint16         fid;
    uint8          rsv[2];
    uint32         flag :16;         /**<ctc_l2_dft_vlan_flag_t */
    uint32         cid :16;
    uint32         mc_gid :20;
    uint32         share_grp_en :1;
    uint32         xdata_en:1;
    uint32         rsv1 :10;
}sys_l2_fid_node_t;

struct sys_l2_node_s
{
    mac_addr_t mac;
    uint16     fid;

    uint32         flag;         /**< ctc_l2_flag_t */
    uint32         ecmp_valid :1;
    uint32         aps_valid  :1;
    uint32         bind_nh    :1;
    uint32         rsv_ad     :1;
    uint32         use_destmap_profile : 1;
    uint32         rsv        :27;
    uint32         nh_id;        /*only used for bind nexthop,else is zero*/
    sys_l2_ad_t*   adptr;        /**< if NULL, indicate not use spool */
    uint32         key_index;

};
typedef struct sys_l2_node_s   sys_l2_node_t;

typedef enum
{
    SYS_L2_ADDR_TYPE_UC,
    SYS_L2_ADDR_TYPE_MC,
    SYS_L2_ADDR_TYPE_DEFAULT
}sys_l2_addr_type_t;

struct mc_mem_s
{
    uint8    is_assign;
    uint8    with_nh;
    uint8    is_ul_nh;
    uint32   mem_port;
    uint32   nh_id;
    uint8    remote_chip;
    uint8 gchip_id;
    uint8 port_bmp_en;
    ctc_port_bitmap_t  port_bmp;
} ;
typedef struct mc_mem_s   mc_mem_t;

struct sys_l2_flush_fdb_s
{
    mac_addr_t mac;
    uint16 fid;
    uint32 gport;
    uint8  flush_flag;
    uint8  flush_type;
    uint8  use_logic_port;
    uint8  lchip;
};

typedef struct sys_l2_flush_fdb_s sys_l2_flush_fdb_t;

typedef struct
{
    uint32 key_index[40];
    uint8  index_cnt;
    uint8  rsv[3];
    uint8  level[40];
}sys_l2_calc_index_t;

/* proved neccsary. like init default entry. */
typedef struct
{
    union {
        ctc_l2_addr_t  l2_addr;
        ctc_l2_mcast_addr_t l2mc_addr;
        ctc_l2dflt_addr_t l2df_addr;

    }addr;

    uint8         addr_type;     /**< refer to sys_l2_addr_type_t */

    uint32         key_valid:1;
    uint32         pending:1;
    uint32         rsv_ad_index:1;
    uint32         with_nh :1;       /**< used for build ad_index with nexthop */
    uint32         revert_default:1;
    uint32         merge_dsfwd:1;
    uint32         ecmp_valid:1; /*ecmp or ecmp interface*/
    uint32         aps_valid:1;

    uint32         mc_nh:1;
    uint32         is_logic_port:1; /*used for uc & binding nhid and logic port*/
    uint32         bind_nh:1;
    uint32         nh_ext:1;
    uint32         cloud_sec_en:1;
    uint32         by_pass_ingress_edit:1;
    uint32         is_exist:1;
    uint32         share_grp_en:1;
    uint32         adjust_len:8;
    uint32         use_lp:1;
    uint32         use_destmap_profile:1;
    uint32         h_ecmp             :1;
    uint32         tunnel_ecmp_high   :1;
    uint32         overlay_nh   :1; /*Vxlan overlay nexthop, for AT*/
    uint32         xdata_en     :1;
    uint32         g_xdata_info :1;
    uint32         ad_alloc:1;
    
    uint32         xgpon_en:1;
    uint32         hw_reset:1;
	uint32         srv6_nh:1;
    uint32         rsv:29;

    uint32        nhid;          /**< use it directly if with_nh is true */
    uint32        fwd_ptr;
    uint32        dsnh_offset;
    uint32        tunnel_id;

    uint32        destmap;     /*for ecmp, means ecmp group id*/

    uint32        key_index;
    uint32        ad_index;
    sys_l2_xdata_info_t xdata;
    sys_nh_info_dsnh_t  nh_info_dsnh;
}sys_l2_info_t;

struct sys_l2_destmap_profile_fdb_s
{
    uint8 lchip;
    ctc_l2_fdb_query_t* pq;
    ctc_l2_fdb_query_rst_t* pr;
    sys_l2_detail_t* p_detail;
};
typedef struct sys_l2_destmap_profile_fdb_s sys_l2_destmap_profile_fdb_t;
struct sys_l2_hash_reorder_s
{
    mac_addr_t mac;
    uint16     fid;
    uint8      aging_timer; /*0, disable; 1, normal; 3, pending timer*/
    uint8      hit;
    uint32     ad_index;
    uint32     target_idx;
};
typedef struct sys_l2_hash_reorder_s sys_l2_hash_reorder_t;
struct sys_l2_ad_update_node_s
{
    ctc_list_pointer_node_t head;
    ctc_list_pointer_node_t nhid_list_head;
    uint32  ad_index;
    uint32  ldp;
    uint32  srv6_nhid;
};
typedef struct sys_l2_ad_update_node_s sys_l2_ad_update_node_t;

#define SYS_L2_REG_SYN_ADD_DB_CB(lchip, add) pl2_usw_master[lchip]->sync_##add##_db = _sys_usw_l2_add_indrect;
#define SYS_L2_REG_SYN_DEL_DB_CB(lchip, remove) pl2_usw_master[lchip]->sync_##remove##_db = _sys_usw_l2_remove_indrect;
#define SYS_L2_ONE_BLOCK_ENTRY_NUM 4
#define SYS_L2_FLEX_OP_MAX_NUM 262143


/**********************************************************************************
                      Define API function interfaces
 ***********************************************************************************/

extern int32
sys_usw_l2_fdb_init(uint8 lchip, void* l2_fdb_global_cfg);

int32
sys_usw_l2_set_default_entry_features(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

int32
sys_usw_l2_get_default_entry_features(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

extern int32
sys_usw_l2_get_fdb_count(uint8 lchip, ctc_l2_fdb_query_t* pQuery);

extern int32
sys_usw_l2_get_fdb_entry(uint8 lchip, ctc_l2_fdb_query_t* pQuery,
                                ctc_l2_fdb_query_rst_t* query_rst);

extern int32
sys_usw_l2_add_fdb(uint8 lchip, ctc_l2_addr_t* l2_addr, uint8 with_nh, uint32 nhid, uint8 force_overwrite);

extern int32
sys_usw_l2_remove_fdb(uint8 lchip, ctc_l2_addr_t* l2_addr);

extern int32
sys_usw_l2_remove_fdb_by_index(uint8 lchip, uint32 index);

extern int32
sys_usw_l2_get_fdb_by_index(uint8 lchip, uint32 index, ctc_l2_addr_t* l2_addr, sys_l2_detail_t* pi);

extern int32
sys_usw_l2_flush_fdb(uint8 lchip, ctc_l2_flush_fdb_t* pFlush);

extern int32
sys_usw_l2_add_default_entry(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

extern int32
sys_usw_l2_remove_default_entry(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

extern int32
sys_usw_l2_add_port_to_default_entry(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

extern int32
sys_usw_l2_remove_port_from_default_entry(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

extern int32
sys_usw_l2mcast_add_addr(uint8 lchip, ctc_l2_mcast_addr_t* l2mc_addr);

extern int32
sys_usw_l2mcast_remove_addr(uint8 lchip, ctc_l2_mcast_addr_t* l2mc_addr);

extern int32
sys_usw_l2mcast_add_member(uint8 lchip, ctc_l2_mcast_addr_t* l2mc_addr);

extern int32
sys_usw_l2mcast_remove_member(uint8 lchip, ctc_l2_mcast_addr_t* l2mc_addr);

extern int32
sys_usw_l2_show_status(uint8 lchip);

extern int32
sys_usw_l2_set_nhid_by_logic_port(uint8 lchip, uint16 logic_port, uint32 nhp_id);

extern int32
sys_usw_l2_get_nhid_by_logic_port(uint8 lchip, uint16 logic_port, uint32 *nhp_id);

 /*extern int32*/
 /*sys_usw_l2_sync_hw_info(uint8 lchip, void* pf);*/

extern int32
sys_usw_l2_set_dsmac(uint8 lchip, uint32 gport, bool b_add);

extern int32
sys_usw_l2_fid_bind_policer_id(uint8 lchip, uint16 fid, uint16 policer_id);
extern int32
sys_usw_l2_fid_get_bind_policer(uint8 lchip, uint16 fid, uint8* policer_valid, uint32 *policer_ptr);

extern int32
sys_usw_l2_set_fid_property(uint8 lchip, uint16 fid_id, uint32 property, uint32 value);

extern int32
sys_usw_l2_get_fid_property(uint8 lchip, uint16 fid_id, uint32 property, uint32* value);

extern int32
sys_usw_l2_set_default_entry_features(uint8 lchip, ctc_l2dflt_addr_t* l2dflt_addr);

extern int32
sys_usw_l2_reserve_rchip_ad_index(uint8 lchip, uint8 gchip, uint16 max_port_num, uint8 rchip_slice_bmp);

extern int32
sys_usw_l2_get_fid_num(uint8 lchip, uint16* p_fid_num);

extern int32
sys_usw_l2_remove_pending_fdb(uint8 lchip, ctc_l2_addr_t* l2_addr, uint32 ad_idx);

extern int32
sys_usw_l2_set_station_move(uint8 lchip, uint32 gport, uint8 type, uint32 logic_port, uint8 enable, uint32 value);

extern int32
sys_usw_l2_get_station_move(uint8 lchip, uint32 gport, uint8 type, uint32* value);

extern bool
sys_usw_l2_fdb_trie_sort_en(uint8 lchip);

extern int32
sys_usw_l2_default_entry_set_mac_auth(uint8 lchip, uint16 fid, bool enable);

extern int32
sys_usw_l2_default_entry_get_mac_auth(uint8 lchip, uint16 fid, bool* enable);

extern int32
sys_usw_l2_fdb_set_entry_hit(uint8 lchip, ctc_l2_addr_t* l2_addr, uint8 hit);

extern int32
sys_usw_l2_fdb_get_entry_hit(uint8 lchip, ctc_l2_addr_t* l2_addr, uint8* hit);

extern int32
sys_usw_l2_fdb_deinit(uint8 lchip);

extern int32
sys_usw_l2_replace_fdb(uint8 lchip, ctc_l2_replace_t* p_replace);
extern int32
sys_usw_l2_fdb_set_search_depth(uint8 lchip, uint32 search_depth);
extern int32
sys_usw_l2_fdb_get_search_depth(uint8 lchip, uint32* p_search_depth);
extern int32
sys_usw_l2_fdb_init_done(uint8 lchip);
extern int32
sys_usw_l2_get_dsmac_base(uint8 lchip, sys_l2_dsmac_base_type_t type);
extern uint16
sys_usw_l2_get_fid_flag(uint8 lchip, uint16 fid);
#ifdef __cplusplus
}
#endif
#endif /*end of _SYS_USW_L2_FDB_H_*/

